﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using KS.DataWrapper.WebApi;
using WebApiHostTest.Models;
using System.Linq.Expressions;
using Newtonsoft.Json;

namespace WebApiHostTest.Controllers
{
    public class TestItemClassController : BaseWebApiWrapperController<TestItemClass>
    {

         /// <summary>
        /// Constructor used by the Web API infrastructure.
        /// </summary>
        public TestItemClassController()
        {
            this.repository = new TestItemClassRepository();
        }

        [Route("api/test_1")]
        public object GetBooks([FromUri]string exp)
        {
            (this.repository as TestItemClassRepository).list.Add(new TestItemClass() { ID = "1" });
            (this.repository as TestItemClassRepository).list.Add(new TestItemClass() { ID = "2" });
            (this.repository as TestItemClassRepository).list.Add(new TestItemClass() { ID = "3" });
            (this.repository as TestItemClassRepository).list.Add(new TestItemClass() { ID = "4" });
            (this.repository as TestItemClassRepository).list.Add(new TestItemClass() { ID = "5" });

            var oloo = (this.repository as TestItemClassRepository).DynamicLinq(exp);

            //Expression ss = (Expression)JsonConvert.DeserializeObject(exp);
            return oloo;
        }

    

        //// GET api/<controller>
        //public IEnumerable<string> Get()
        //{
        //    return new string[] { "value1", "value2" };
        //}

        //// GET api/<controller>/5
        //public string Get(int id)
        //{
        //    return "value";
        //}

        //// POST api/<controller>
        //public void Post([FromBody]
        //                 string value)
        //{
        //}

        //// PUT api/<controller>/5
        //public void Put(int id, [FromBody]
        //                string value)
        //{
        //}

        //// DELETE api/<controller>/5
        //public void Delete(int id)
        //{
        //}
    }
}